/*
*	New C++ File starts here.
*	This file should be named nml_ex1.cc
*/

// Include all NML, CMS, and RCS classes and functions
#include "rcs.hh"

// Include command and status message definitions
#include "nml_ex1.hh"

// Forward Function Prototypes
void nmlupdate(CMS *cms, time_tracker *x);
void initialize_time_tracker(time_tracker *x);
void nmlupdate(CMS *cms, PmCartesian *x);
void initialize_PmCartesian(PmCartesian *x);


#ifndef EX_NAME_LIST_LENGTH
#define EX_NAME_LIST_LENGTH 2
#endif

const NMLTYPE ex_id_list[EX_NAME_LIST_LENGTH]= {
	EXAMPLE_MSG_TYPE, /* 0,101 */
	-1};
const size_t ex_size_list[EX_NAME_LIST_LENGTH]= {
	sizeof(EXAMPLE_MSG),
	0};


// Enumerated Type Constants

/*
Estimated_size	EXAMPLE_MSG	248
Estimated_size	PmCartesian	24
Estimated_size	time_tracker	64
Estimated_size	MAXIMUM	248
*/
/*
*	NML/CMS Format function : ex_format
*	Automatically generated by NML CodeGen Java Applet.
*	on Tue May 13 13:48:33 GMT-05:00 2008
*/
int ex_format(NMLTYPE type, void *buffer, CMS *cms)
{

	type = cms->check_type_info(type,buffer,"ex",
		(cms_symbol_lookup_function_t) 0,
		(const char **) 0,
		ex_id_list,ex_size_list,
		EX_NAME_LIST_LENGTH,
		0);

	switch(type)
	{
	case EXAMPLE_MSG_TYPE:
		((EXAMPLE_MSG *) buffer)->update(cms);
		break;

	default:
		return(0);
	}
	return 1;
}

/*
*	NML/CMS Update function for EXAMPLE_MSG
*	Automatically generated by NML CodeGen Java Applet.
*	on Tue May 13 13:48:33 GMT-05:00 2008
*/
void EXAMPLE_MSG::update(CMS *cms)
{

	cms->beginClass("EXAMPLE_MSG","NMLmsg");
	cms->update_with_name("d",d);
	cms->update_with_name("f",f);
	cms->update_with_name("c",c);
	cms->update_with_name("s",s);
	cms->update_with_name("i",i);
	cms->update_with_name("l",l);
	cms->update_with_name("uc",uc);
	cms->update_with_name("us",us);
	cms->update_with_name("ui",ui);
	cms->update_with_name("ul",ul);
	cms->update_dla_length_with_name("da_length",da_length);
	cms->update_dla_with_name("da",da,da_length,20);

	cms->endClass("EXAMPLE_MSG","NMLmsg");

}


/*
*	NML/CMS Update function for PmCartesian
*	Automatically generated by NML CodeGen Java Applet.
*	on Tue May 13 13:48:33 GMT-05:00 2008
*/
void nmlupdate(CMS *cms,PmCartesian *x)
{

	cms->beginClass("PmCartesian",0);
	cms->update_with_name("x",x->x);
	cms->update_with_name("y",x->y);
	cms->update_with_name("z",x->z);

	cms->endClass("PmCartesian",0);

}


/*
*	NML/CMS Update function for time_tracker
*	Automatically generated by NML CodeGen Java Applet.
*	on Tue May 13 13:48:33 GMT-05:00 2008
*/
void nmlupdate(CMS *cms,time_tracker *x)
{

	cms->beginClass("time_tracker",0);
	cms->update_with_name("count",x->count);
	cms->update_with_name("last",x->last);
	cms->update_with_name("now",x->now);
	cms->update_with_name("start",x->start);
	cms->update_with_name("elapsed",x->elapsed);
	cms->update_with_name("min",x->min);
	cms->update_with_name("max",x->max);
	cms->update_with_name("avg",x->avg);

	cms->endClass("time_tracker",0);

}

/*
*	Initializer for PmCartesian
*	Automatically generated by NML CodeGen Java Applet.
*	on Tue May 13 13:48:33 GMT-05:00 2008
*/
void initialize_PmCartesian(PmCartesian* x)
{
	x->x = (double) 0;
	x->y = (double) 0;
	x->z = (double) 0;

}

/*
*	Initializer for time_tracker
*	Automatically generated by NML CodeGen Java Applet.
*	on Tue May 13 13:48:33 GMT-05:00 2008
*/
void initialize_time_tracker(time_tracker* x)
{
	x->count = (int) 0;
	x->last = (double) 0;
	x->now = (double) 0;
	x->start = (double) 0;
	x->elapsed = (double) 0;
	x->min = (double) 0;
	x->max = (double) 0;
	x->avg = (double) 0;

}

